---
title: "Data Analysis"
author: "Nick Pangakis"
output: pdf_document
---

```{r setup, echo=FALSE, warning=F, message=F}
knitr::opts_chunk$set(echo = TRUE, fig.width=8, fig.height=4,include=T,
                      eval=TRUE, results = T, warning=F, message=F, echo=T)
options(scipen=9999)
if(!require('pacman')) {
  install.packages('pacman')
}
pacman::p_load(ltm, tidyverse, car, grid, ggh4x, mediation) 
```

This script involves the data analysis procedures for the manuscript titled "Fleeing For Their Lives: Reconsidering How Americans View Immigrants’ Reasons for Migrating" by Nicholas Pangakis (Public Opinion Quarterly).

# Load data and minor data cleaning

```{r Load in data}
# Load in pre-cleaned data
data_full <- read_csv("data_clean.csv") %>% 
  # identify respondents who didnt finish the survey
  mutate(no_finish = case_when(is.na(ac_imm_starv) & is.na(ac_imm_violence) 
                               & is.na(ac_lina_starv) & is.na(ac_lina_violence) ~ 1, 
                               TRUE ~ 0),
         # make gender binary
         gender = gender - 1)
```

```{r Final data cleaning}
# helper function
count_na <- function(x){
  sum(is.na(x))
}

# filter out respondents who didnt finish survey
data <- data_full %>% 
  # filter out people who didn't finish the survey --> 298 respondents 
  # This is b/c people were restricted to fill out survey on laptops. Many opened on phones and closed.
  filter(no_finish == 0) %>% 
  mutate(count_na = apply(.[c("DV1_lina", "DV2_policy", "DV3_blame",
                              "priority_poverty", "priority_violence")], 
                          1, count_na)) %>% 
  # drop if they didn't answer 3 of the DV questions: only drops 2 people
  filter(count_na < 3)

# explore null values - 20 respondents didn't answer at least one question about DV
null_values <- data %>% 
  filter(count_na > 0) 

#impute mean for remaining missing values (only 24 respondents) - results don't change if you just drop them
data[sapply(data, is.numeric)] <- sapply(data[sapply(data, is.numeric)], 
                                                 function(x) {
                                                   ifelse(is.na(x), 
                                                          mean(x, na.rm = TRUE), x)
                                                   })

# make variables callable
attach(data)
rm(null_values,count_na)
```



# Minor Experimental Assessments

```{r attention checks}

# passed attention check
data %>% 
  filter(attention_check_main == 2) %>% 
  nrow() / nrow(data)

# 0.062 % failed attention check (93.8% of respondents passed)

# passed multiple attention checks
data %>% 
  mutate(AC_2_val = case_when((attention_check_main == 2 & 
                                ac_lina_violence_binary == 1 & 
                                violence == 1) | 
                                (attention_check_main == 2 & 
                                ac_lina_starv_binary == 1 & 
                                starvation == 1) |
                                (attention_check_main == 2 & 
                                control == 1) ~ 1, TRUE ~ 0)) %>% 
  filter(AC_2_val == 1) %>% 
  nrow() / nrow(data)

# 0.1206 % failed either any of the attention checks (87.9% pass)
  
```

```{r Minor Experimental Assessments}
# Check length of survey - 5.25 minutes
median(data$Duration__in_seconds_)/60

##### Check reliability of survey batteries
#DV1: Attitudes toward Hypothetical Family of Migrants - 0.897 good
data %>% 
  dplyr::select(DV1___1,
         DV1___2,
         DV1___3,
         DV1___4) %>% 
  cronbach.alpha()


#DV2: Immigration Policy Attitudes - .842 good
data %>% 
  dplyr::select(DV2___1,
         DV2___2,
         DV2___3,
         priority_poverty,
         priority_violence) %>% 
  cronbach.alpha()

#dv3: blame - 0.628 decent
data %>% 
  dplyr::select(Q4_3,
         Q4_4) %>% 
  cronbach.alpha()

#manipulation check: Voluntariness - 0.529 bad
data %>% 
  dplyr::select(Q4_1,
                Q4_2) %>% 
  cronbach.alpha()

# blame and voluntariness - .745 pretty good
data %>% 
  dplyr::select(Q4_1,
                Q4_2,
                Q4_3,
                Q4_4) %>% 
  cronbach.alpha()

detach(package:ltm,unload=TRUE)

```

Some important aspects of the experiment: Average length of survey was 5.25 minutes. 93.6% of respondents passed first attention check. 87.9% of respondents passed multiple attention checks. Respondents were restricted to only answer the survey on their laptop, which led to a number of void surveys because many people opened on their phone and immediately closed. This phenomenon is explored in greater detail below as well as in the supplemental material (S1). 

Because the Cronbach alpha levels for the MC were low, I also analyze each item separately. Full Cronbach's alpha levels:
 - DV1: Attitudes toward Hypothetical Family of Migrants - 0.89 good
 - DV2: Immigration Policy Attitudes - .84 good
 - DV3: Blame - 0.632 decent
 - MC: Manipulation check (voluntariness) - 0.53 poor
 - Voluntariness and blame combined - 0.745 decent

# Analysis of Main Results

This section builds a variety of regression models to analyze the experimental results.

```{r}
# Create function to analyze treatment effects
analyze_results <- function(dv, dv_name, interaction){
  if (interaction == FALSE) {
    ### main models
    
    # base model
    model_no_covariates <- lm(dv ~ condition, data = data)
    # main covariates
    model <- lm(dv ~ condition + political_party_preference + education,
         data = data)
    # effects as percentages
    model_per <- lm(log(dv) ~ condition + political_party_preference + education,
              data=data)
    
  } else {
    ### interaction models
    
    print("Party interaction")
    model <- lm(dv ~ condition*political_party_preference_reduced,
         data = data)
    print(summary(model))
    
    print("education interaction")
    model <- lm(dv ~ condition*education,
         data = data)
    print(summary(model))
    
    print("Hispanic interaction")
    model <- lm(dv ~ condition*hispanic,
         data = data)
    print(summary(model))
    
    print("Low income interaction")
    data_temp <- data %>% 
      mutate(income_low = case_when(income < 3 ~ 1, TRUE ~ 0 ))
    model <- lm(dv ~ condition*income_low,
         data = data_temp)
    print(summary(model))

    return(NULL)
  }
  
  # Regression results
  print("Main regression results:")
  print(summary(model))
  
  # Regression results - no covariates
  print("Regression results (no covariates):")
  print(summary(model_no_covariates))
  
  # Regression results - as percent changes
  print("Regression results (log dv):")
  print(summary(model_per))
  
  results <- summary(model)[["coefficients"]]
  
  mat <- matrix(nrow = 2, ncol = 4)
  # starvation_effect
  mat[1,1] <- "Economic Threat"
  mat[1,2] <- round(results[2,1],3)
  # starvation_se
  mat[1,3] <- round(results[2,2],3)
  # violence_effect
  mat[2,1] <- "Violence Threat"
  mat[2,2] <- round(results[3,1],3)
  # starvation_se
  mat[2,3] <-round(results[3,2],3)
  mat[,4] <- dv_name
  
  return(mat)
}
```

### Main results

```{r}
fam <- analyze_results(DV1_lina, 
                       "Admit Family Into Country", interaction = FALSE)

mc1 <- analyze_results(manipulation_check, 
                             "Migration Decision Involuntary Index", 
                             interaction = FALSE)

# Analyze MC items separately due to low Cronbach alpha
mc2 <- analyze_results(Q4_1, 
                             "Migration Decision Involuntary Item 1", 
                             interaction = FALSE)
mc3 <- analyze_results(Q4_2, 
                             "Migration Decision Involuntary Item 2", 
                             interaction = FALSE)

blame <- analyze_results(DV3_blame, 
                         "Immigrant Family to Blame for Situation", 
                         interaction = FALSE)
# make blame dv negative
blame <- as.data.frame(blame)
colnames(blame) <- c("Condition", "Effect", "SE", "DV")
blame <- blame %>% 
  mutate(Effect = -as.numeric(Effect),
         SE = -as.numeric(SE))
blame <- as.matrix(blame)

### Policy Qs
policy <- analyze_results(DV2_policy, 
                          "Immigration Policy Index", interaction = FALSE)

priority_pov <- analyze_results(priority_poverty, "Prioritize Immigrants Facing Poverty", 
                                interaction = FALSE)

priority_v <- analyze_results(priority_violence, "Prioritize Immigrants Facing Violence", 
                              interaction = FALSE)

admit <- analyze_results(DV2___1, "Admit More Immigrants", 
                         interaction = FALSE)

deport <- analyze_results(DV2___2, "Decrease Deportations", 
                          interaction = FALSE)

risk <- analyze_results(DV2___3, "Admit Immigrants With Lives at Risk", 
                        interaction = FALSE)

# Behavior
behavior <- analyze_results(behavior_q, 
                            "Willingness to Donate to Immigration Organization", 
                            interaction = FALSE)

```

## Manipulation check plot

```{r}
resultsmain_mc <- rbind(mc1, mc2, mc3)
resultsmain_mc <- as.data.frame(resultsmain_mc)
resultsmain_mc$label <- "Manipulation Check: Migration Voluntariness"
colnames(resultsmain_mc) <- c("Condition", "Effect", "SE", "DV","label")
```

```{r} 
(mc_plot <- resultsmain_mc %>% 
  mutate(Effect = as.numeric(Effect),
         SE = as.numeric(SE),
         DV = as.factor(DV),
         DV = fct_relevel(DV, c("Migration Decision Involuntary Item 2",
                                "Migration Decision Involuntary Item 1",
                                "Migration Decision Involuntary Index"))) %>% 
  
  ggplot(aes(y = DV, x = Effect, color = Condition, shape = Condition)) +
  geom_point(size = 3,position=position_dodge(width=0.5)) +
  geom_errorbar(aes(xmin = Effect - (2*SE), xmax = Effect + (2*SE)),width=.4,
                position=position_dodge(width=0.5)) +
  geom_errorbar(aes(xmin = Effect - (1.645 * SE), xmax = Effect + (1.645 * SE)),
                width = 0.35, position = position_dodge(width = 0.5), linetype = "dashed") +
  geom_vline(xintercept = 0,
             linetype = "longdash",
             color = "black") +
  labs(title=str_wrap("Manipulation Check: Migration Voluntariness",45),
       y= "Outcome Measure",
       x="Effect Size",
       caption = str_wrap("Note: Treatment effects using multiple regression relative to the no threat condition. Inner error bars are 90% confidence intervals and outer error bars ar 95%.",95)
      ) +
  theme_bw() + 
  scale_y_discrete(labels = function(x) str_wrap(x, width = 20)) +
  theme(plot.title = element_text(hjust=0.5),
        text = element_text(size=13),
        legend.position="top")
)

```

```{r}
pdf("manipulation_check.pdf")
print(mc_plot)    
dev.off() 
```

## Main plot - attitudes toward family

```{r}
# combine results
resultsmain_1 <- rbind(fam, blame)
resultsmain_1 <- as.data.frame(resultsmain_1)
resultsmain_1$label <- "Attitudes Toward Immigrant Family in Article"
colnames(resultsmain_1) <- c("Condition", "Effect", "SE", "DV","label")

```

```{r} 
(main_plot <- resultsmain_1 %>% 
  mutate(Effect = as.numeric(Effect),
         SE = as.numeric(SE),
         DV = as.factor(DV),
         DV = fct_relevel(DV, c("Immigrant Family to Blame for Situation",
                                "Admit Family Into Country"))) %>% 
  
  ggplot(aes(y = DV, x = Effect, color = Condition, shape = Condition)) +
  geom_point(size = 3,position=position_dodge(width=0.5)) +
  geom_errorbar(aes(xmin = Effect - (2*SE), xmax = Effect + (2*SE)),width=.4,
                position=position_dodge(width=0.5)) +
  geom_errorbar(aes(xmin = Effect - (1.645 * SE), xmax = Effect + (1.645 * SE)),
                width = 0.35, position = position_dodge(width = 0.5), linetype = "dashed") +
  geom_vline(xintercept = 0,
             linetype = "longdash",
             color = "black") +
  labs(title=str_wrap("Comparing the Effects of Economic and Violence Threats as Reasons for Migration",45),
       y= "Outcome Measure",
       x="Effect Size"

      ) +
  theme_bw() + 
  scale_y_discrete(labels = function(x) str_wrap(x, width = 20)) +
  theme(plot.title = element_text(hjust=0.5),
        text = element_text(size=13),
        legend.position="top")
)
```

```{r}
pdf("main_results_family.pdf")
print(main_plot)    
dev.off() 
```

## Main plot - policy

```{r}
resultsmain_2 <- rbind(policy, priority_pov, priority_v, admit, deport, risk)
resultsmain_2 <- as.data.frame(resultsmain_2)
resultsmain_2$label <- "Attitudes Toward Immigration Policy"
colnames(resultsmain_2) <- c("Condition", "Effect", "SE", "DV","label")

```

```{r}
(main_plot2 <- resultsmain_2 %>% 
  mutate(Effect = as.numeric(Effect),
         SE = as.numeric(SE),
         DV = as.factor(DV),
         DV = fct_relevel(DV, c("Admit Immigrants With Lives at Risk",
                                "Decrease Deportations", 
                                "Admit More Immigrants", 
                                "Prioritize Immigrants Facing Violence",
                                "Prioritize Immigrants Facing Poverty",
                                "Immigration Policy Index"))) %>% 
  ggplot(aes(y = DV, x = Effect, color = Condition, shape = Condition)) +
  geom_point(size = 3,position=position_dodge(width=0.5)) +
  geom_errorbar(aes(xmin = Effect - (2*SE), xmax = Effect + (2*SE)),width=.6,
                position=position_dodge(width=0.5)) +
    geom_errorbar(aes(xmin = Effect - (1.645 * SE), xmax = Effect + (1.645 * SE)),
                width = 0.5, position = position_dodge(width = 0.5), linetype = "dashed") +
  geom_vline(xintercept = 0,
             linetype = "longdash",
             color = "black") +
  labs(title=str_wrap("Effects of Economic and Violence Threats on Policy Attitudes",40),
       y= "Outcome Measure",
       x="Effect Size"
      ) +
  theme_bw() + 
  scale_y_discrete(labels = function(x) str_wrap(x, width = 20)) +
  theme(plot.title = element_text(hjust=0.5),
        text = element_text(size=13),
        legend.position="top")
)
```

```{r}
pdf("main_results_policy.pdf")
print(main_plot2)    
dev.off() 
```

# Mediation Analysis

```{r}
set.seed(42)
data_mediation <- data %>% 
  mutate(violence = case_when(condition == "Violence" ~ 1, TRUE ~ 0),
         starvation = case_when(condition == "Starvation" ~ 1, TRUE ~ 0))

# violence
model1 <- lm(DV1_lina ~ violence + political_party_preference + education, 
             data = data_mediation)
model2 <- lm(DV2_policy ~ DV1_lina + violence + political_party_preference + education, 
             data = data_mediation)
med.out <- mediate(model1, model2, treat = "violence", mediator = "DV1_lina", 
                   robustSE = TRUE, sims = 1000)
summary(med.out)

sens.out <- medsens(med.out, rho.by = 0.1, effect.type = "indirect", 
                    sims = 1000)
summary(sens.out)
```


```{r}
set.seed(42)
# starvation
model1 <- lm(DV1_lina ~ starvation + political_party_preference + education, 
             data = data_mediation)
model2 <- lm(DV2_policy ~ DV1_lina + starvation + political_party_preference + education, 
             data = data_mediation)
med.out <- mediate(model1, model2, treat = "starvation", mediator = "DV1_lina", 
                   robustSE = TRUE, sims = 1000)
summary(med.out)

sens.out2 <- medsens(med.out, rho.by = 0.1, effect.type = "indirect", 
                     sims = 1000)
summary(sens.out2)
par(mfrow = c(1, 2))

plot(sens.out2, main = "Immigrant Perceptions\n(Economic Threat)")
plot(sens.out,main="Immigrant Perceptions\n(Violence Threat)")
mtext("Support for Pro-Immigration Policies", side = 3,  line = -16.5, outer = TRUE)
```


# Attention Checks

Attention checks were included at the end of the survey after measuring the dependent variables. Respondents were asked why the Lina family tried to come to the United States. Respondents were encouraged to select all options that applied, and the options ranged from (a) economic opportunity, (b) avoid starvation, (c) avoid persecution and violence, and (d) unsure. Higher values indicate increased likelihood that the family traveled for the specified reason.

```{r}
# summary stats for AC
# Create function to calculate mode
Mode <- function(x) {
  ux <- unique(x)
  ux[which.max(tabulate(match(x, ux)))]
}

data %>% 
  group_by(condition) %>% 
  summarize(mode_lina_violence = Mode(ac_lina_violence),
            mean_lina_violence = mean(ac_lina_violence),
            mode_lina_starv = Mode(ac_lina_starv),
            mean_lina_starv = mean(ac_lina_starv),
            mode_imm_violence = Mode(ac_imm_violence),
            mean_imm_violence = mean(ac_imm_violence),
            mode_imm_starv = Mode(ac_imm_starv),
            mean_imm_starv = mean(ac_imm_starv))
```


```{r}
# analyze attention checks
lina_violence <- analyze_results(ac_lina_violence, "Immigrant Family Fled Violence", 
                                 interaction = FALSE)
lina_starv <- analyze_results(ac_lina_starv, "Immigrant Family Fled Starvation", 
                              interaction = FALSE)
imm_viol_res <- analyze_results(ac_imm_violence, 
                            "More Immigrants Flee Violence", interaction = FALSE)
imm_starv_res <- analyze_results(ac_imm_starv, 
                             "More Immigrants Flee Starvation", interaction = FALSE)
```


# Descriptive Statistics

```{r}
# All respondents
data_describe_all <- data %>% 
  filter(no_finish == 0) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Finshed Survey")

summary(data$Duration__in_seconds_) 

# Descriptives by condition - control
data_describe_control <- data %>% 
  filter(control == 1) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Control Condition")

summary(data[control == 1,]$Duration__in_seconds_)

# Descriptives by condition - violence
data_describe_violence <- data %>% 
  filter(violence == 1) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Violence Condition")

summary(data[violence == 1,]$Duration__in_seconds_)

# Descriptives by condition - economic
data_describe_economic <- data %>% 
  filter(starvation == 1) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Starvation Condition")

summary(data[starvation == 1,]$Duration__in_seconds_)

# Descriptives --- didnt finish survey
data_describe_nofinish <- data_full %>% 
  filter(no_finish == 1) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Didn't Finish Survey")

no_finish_respondents <- data_full %>% 
  filter(no_finish == 1) 

# Respondents who didnt finish mostly opened and closed survey in 11 seconds
summary(no_finish_respondents$Duration__in_seconds_)

# # Descriptives --- failed attention check
data_describe_fail_ac <- data %>% 
  filter(attention_check_main != 2) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Failed Attention Check")

# Respondents who failed attention check spent less time reading the treatment information
summary(data[attention_check_main != 2,]$Duration__in_seconds_)

# # Descriptives --- failed multiple attention checks
data_describe_fail_ac2 <- data %>% 
  mutate(AC_2_val = case_when((attention_check_main == 2 & 
                                ac_lina_violence_binary == 1 & 
                                violence == 1) | 
                                (attention_check_main == 2 & 
                                ac_lina_starv_binary == 1 & 
                                starvation == 1) |
                                (attention_check_main == 2 & 
                                control == 1) ~ 1, TRUE ~ 0)) %>% 
  filter(AC_2_val == 0) %>% 
  select(education, hispanic, income, gender,
         political_party_preference) %>% 
  skimr::skim() %>% 
  select(2, 5, 6) %>% 
  mutate(subset = "Failed Multiple AC")

fail_ac_respondents <- data %>% 
  mutate(AC_2_val = case_when((attention_check_main == 2 & 
                                ac_lina_violence_binary == 1 & 
                                violence == 1) | 
                                (attention_check_main == 2 & 
                                ac_lina_starv_binary == 1 & 
                                starvation == 1) |
                                (attention_check_main == 2 & 
                                control == 1) ~ 1, TRUE ~ 0)) %>% 
  filter(AC_2_val == 0)

summary(fail_ac_respondents$Duration__in_seconds_)
```


```{r}
descriptive_table <- rbind(data_describe_all, data_describe_nofinish, 
                           data_describe_fail_ac, data_describe_fail_ac2)

(descriptive_plot1 <- descriptive_table %>% 
  ggplot(aes(x = skim_variable, y = numeric.mean, fill = subset)) +
  geom_col(position = position_dodge()) +
  geom_text(aes(label=subset), position=position_dodge(width=1),hjust = 0.1) +
  labs(x = "Variable", y = "Mean", fill = "") +
  theme_bw() +
  coord_flip() +
  guides(fill = "none") +
  scale_y_continuous(limits = c(0, 6)))
```

```{r}
pdf("descriptive_plot1.pdf")
print(descriptive_plot1)    
dev.off() 
```


```{r}
descriptive_table2 <- rbind(data_describe_all,
                           data_describe_control, 
                           data_describe_violence, data_describe_economic)

(descriptive_plot2 <- descriptive_table2 %>% 
  ggplot(aes(x = skim_variable, y = numeric.mean, fill = subset)) +
  geom_col(position = position_dodge()) +
  geom_text(aes(label=subset), position=position_dodge(width=1),hjust = 0.1) +
  labs(x = "Variable", y = "Mean", fill = "") +
  theme_bw() +
  coord_flip() +
  guides(fill = "none")+
  scale_y_continuous(limits = c(0, 6)))
```

```{r}
pdf("descriptive_plot2.pdf")
print(descriptive_plot2)    
dev.off() 
```


```{r}
# check whether there is a meaningful difference between the means in some of these vars

t.test(no_finish_respondents$income, data$income)
t.test(no_finish_respondents$education, data$education)

```

Respondents who didn't finish the survey have slightly lower education and income, which is discussed in greater detail in S1.

# Supplemental Analyses

## Interactions

```{r}
fam_inter <- analyze_results(DV1_lina, "Attitudes Toward Immigrant Family", interaction = TRUE)
policy_inter <- analyze_results(DV2_policy, "Attitudes Toward Immigration Policy", interaction = TRUE)
```


## Cohens D
```{r}
#install.packages("lsr")
library(lsr)
# Lina Family -starvation
group1 <- data %>% filter(control==1) %>% dplyr::select(DV1_lina)
group1_num <- group1$DV1_lina
group2 <- data %>% filter(starvation==1) %>% dplyr::select(DV1_lina)
group2_num <- group2$DV1_lina
cohensD(group1_num, group2_num)
# Lina Family -violence
group1 <- data %>% filter(control==1) %>% dplyr::select(DV1_lina)
group1_num <- group1$DV1_lina
group2 <- data %>% filter(violence==1) %>% dplyr::select(DV1_lina)
group2_num <- group2$DV1_lina
cohensD(group1_num, group2_num)

# Lina Family -starvation
group1 <- data %>% filter(control==1) %>% dplyr::select(DV3_blame)
group1_num <- group1$DV3_blame
group2 <- data %>% filter(starvation==1) %>% dplyr::select(DV3_blame)
group2_num <- group2$DV3_blame
cohensD(group1_num, group2_num)
# Lina Family -violence
group1 <- data %>% filter(control==1) %>% dplyr::select(DV3_blame)
group1_num <- group1$DV3_blame
group2 <- data %>% filter(violence==1) %>% dplyr::select(DV3_blame)
group2_num <- group2$DV3_blame
cohensD(group1_num, group2_num)

```

Effect of starvation threat on family attitudes d = 0.192. Effect of violence threat on family attitudes d = 0.269.

## Double check main results after AC

```{r AC1 }
AC_1 <- data %>% 
  filter(attention_check_main == 2)
rm(data)
data <- data.frame(AC_1)
attach(data)
fam <- analyze_results(DV1_lina, 
                       "Admit Into Country", interaction = FALSE)

policy <- analyze_results(DV2_policy, 
                          "Immigration Policy Index", 
                          interaction = FALSE)

blame <- analyze_results(DV3_blame, 
                         "Immigrant Family to Blame for Situation", 
                         interaction = FALSE)

```
